Fix: add migration#1307
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9ed1f1c to
177935a
Compare
177935a to
3db4486
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds a database migration to modify the builds table by making the end_at column nullable. The change allows build records to be created without requiring an end timestamp, which is useful for tracking builds that are still in progress.
- Adds a new migration file to alter the
builds.end_atcolumn from NOT NULL to nullable - Updates the migration module to include the new migration in the migration list
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| jupiter/src/migration/mod.rs | Registers the new migration in the module and migration list |
| jupiter/src/migration/m20250804_151214_alter_builds_end_at.rs | Implements the database migration to make end_at column nullable |
| ) | ||
| .await?; | ||
| } | ||
| DatabaseBackend::Sqlite | DatabaseBackend::MySql => {} |
There was a problem hiding this comment.
The migration only handles PostgreSQL but ignores SQLite and MySQL backends. This could lead to inconsistent database schemas across different database types. Consider implementing the equivalent ALTER TABLE statements for these backends or add a comment explaining why they're not needed.
| DatabaseBackend::Sqlite | DatabaseBackend::MySql => {} | |
| DatabaseBackend::Sqlite => { | |
| // SQLite: ALTER TABLE builds ALTER COLUMN end_at DROP NOT NULL | |
| // SQLite supports altering column nullability via SeaORM migration | |
| manager | |
| .alter_table( | |
| Table::alter() | |
| .table(Builds::Table) | |
| .modify_column(timestamp_null(Builds::EndAt).to_owned()) | |
| .to_owned(), | |
| ) | |
| .await?; | |
| } | |
| DatabaseBackend::MySql => { | |
| // MySQL: ALTER TABLE builds MODIFY end_at TIMESTAMP NULL | |
| manager | |
| .alter_table( | |
| Table::alter() | |
| .table(Builds::Table) | |
| .modify_column(timestamp_null(Builds::EndAt).to_owned()) | |
| .to_owned(), | |
| ) | |
| .await?; | |
| } |
| ) | ||
| .await?; | ||
| } | ||
| DatabaseBackend::Sqlite | DatabaseBackend::MySql => {} |
There was a problem hiding this comment.
The down migration also only handles PostgreSQL. If the up migration is ever extended to support other backends, the down migration should be updated accordingly to maintain consistency.
| DatabaseBackend::Sqlite | DatabaseBackend::MySql => {} | |
| DatabaseBackend::Sqlite | DatabaseBackend::MySql => { | |
| // No action required for Sqlite or MySql. | |
| // If the up migration is extended to support these backends, | |
| // update this arm accordingly to maintain consistency. | |
| } |
对orion-server的数据库表字段修改进行迁移,将end_at字段改为允许为空